package cn.rojao.wx.config.mybatis;


import javax.sql.DataSource;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

import com.alibaba.druid.pool.DruidDataSource;

/**
 * Created by mickjoust on 2016/4/13.
 * com.hjf.boot.api.config
 */
@Configuration
public class DataSourceConfig {
	
	@Value("${url}")
	public String url;
	@Value("${driverClassName}")
	public String driverClassName;
	@Value("${mysqlusername}")
	public String mysqlusername;
	@Value("${password}")
	public String password;

    
    @Bean
    @Primary  
    public DataSource dataSource() { 
    	System.out.println("----------------password:"+password+"------mysqlusername:"+mysqlusername);
        DruidDataSource datasource = new DruidDataSource();  
        datasource.setUrl(url);  
        datasource.setDriverClassName(driverClassName);          
        datasource.setUsername(mysqlusername);  
        datasource.setPassword(password);           
        return datasource;  
    }

}
